package cn.rongdao.jrkabao.ui.main.mainfragment.loanfragment.uicomponent;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.rongdao.jrkabao.R;

/**
 * Created by jack on 2017/5/27
 */

public class CheckAllProductUIComponent extends LinearLayout {
    public CheckAllProductUIComponent(@NonNull Context context) {
        super(context);
    }

    public CheckAllProductUIComponent(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CheckAllProductUIComponent(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private TextView tvCheckAllProduct;
    private TextView tvAddCard;

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tvCheckAllProduct = findViewById(R.id.llfv_tv_check);
        tvAddCard = findViewById(R.id.llfv_add_card);
    }

    public void setContent(String text) {
        setVisibility(View.VISIBLE);
        setBackgroundColor(Color.WHITE);
        tvCheckAllProduct.setVisibility(View.VISIBLE);
        tvCheckAllProduct.setText(text);
    }

    public void setAddCardContent(String content) {
        setVisibility(View.VISIBLE);
        tvAddCard.setBackgroundResource(R.drawable.main_bg_btn_8radius);
        tvAddCard.setTextColor(Color.WHITE);
        tvAddCard.setVisibility(View.VISIBLE);
        tvAddCard.setText(content);
    }

    public void setAddCardIsEnable(boolean isEnable) {
        tvAddCard.setEnabled(isEnable);
    }

    public void setOnAddCardClickListener(OnClickListener onClickListener) {
        tvAddCard.setOnClickListener(onClickListener);
    }

    public void setPayWayContent(String content) {
        setVisibility(View.VISIBLE);
        tvAddCard.setTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
        tvAddCard.setVisibility(VISIBLE);
        tvAddCard.setText(content);
    }
}
